/**
 * Created by sfr on 2017/10/10.
 */
import React from "react";
import {connect} from "dva";
import { routerRedux } from 'dva/router';
import moment from 'moment';
import {ImagePicker, Button, TextareaItem } from "antd-mobile";
import styles from './newsAdd.less';
const empty = require('is-empty');

class NewsAdd extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      files: [],
    };
  }
  //==生命周期--页面渲染
  render() {
    const { files } = this.state;
    return (
      <div className='newsAdd' style={{backgroundColor: '#eee'}}>
        <TextareaItem
          autoHeight
          placeholder="请输入你想要发布的内容"
          labelNumber={5}
          style={{padding: '0 0.3rem'}}
        />
        <div className={styles.imgeUploader}>
          <ImagePicker
            files={files}
            onChange={this.onChange}
            onImageClick={(index, fs) => console.log(index, fs)}
            selectable={files.length < 9}
          />
        </div>
        <div className={styles.addBtn}> 
          <Button >发布</Button>
        </div>
      </div>
    );
	}
  //==组件所有函数
  //上传图片
  onChange = (files, type, index) => {
    console.log(files, type, index);
    this.setState({
      files,
    });
  }
}

function mapStateToProps({ infor }){
  return {
    infor
	};
}
export default connect(mapStateToProps)(NewsAdd);